package zhihuilan.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import zhihuilan.entity.MyOrderInvoiceStaff;
import zhihuilan.mapper.MyOrderInvoiceStaffMapper;
import zhihuilan.service.MyOrderInvoiceStaffService;

import java.util.List;

@Service
public class MyOrderInvoiceStaffServiceImpl extends ServiceImpl<MyOrderInvoiceStaffMapper, MyOrderInvoiceStaff> implements MyOrderInvoiceStaffService {


    @Override
    public MyOrderInvoiceStaff selectOrderInvoiceStaffById(Integer id){
        return baseMapper.selectById(id);
    }

    @Override
    public Integer insertNew(MyOrderInvoiceStaff myOrderInvoiceStaff){
        return baseMapper.insert(myOrderInvoiceStaff);
    }


    @Override
    public MyOrderInvoiceStaff updateOrderInvoiceStaffById(MyOrderInvoiceStaff myOrderInvoiceStaff){

        Integer i= baseMapper.updateById(myOrderInvoiceStaff);
        if(i>0){
            return  myOrderInvoiceStaff;
        }
        return null;
    }

    @Override
    public void updateOrderInvoiceDefaultByStaff(Integer staffId){
        QueryWrapper<MyOrderInvoiceStaff> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("staffid",staffId);
        queryWrapper.eq("`default`",1);
        MyOrderInvoiceStaff myOrderInvoiceStaff = new MyOrderInvoiceStaff();
        myOrderInvoiceStaff.setDefaultStr(0);
        baseMapper.update(myOrderInvoiceStaff,queryWrapper);
    }

    @Override
    public List<MyOrderInvoiceStaff> OrderInvoiceStaffList(Integer staffid, Integer type){
        QueryWrapper<MyOrderInvoiceStaff> queryWrapper = new QueryWrapper<>();
        queryWrapper.eq("staffid",staffid);
        queryWrapper.eq("type",type);
        return baseMapper.selectList(queryWrapper);
    }

    @Override
    public Integer delOrderInvoiceStaff(Integer id){
        return  baseMapper.deleteById(id);
    }
}
